<html><head><title>BindMenuEvent</title></head>
<body bgcolor="#EFF1F0" link="#3A3966" vlink="#000000" alink="#000000">
<font face="Verdana, sans-serif" size="2"><p align="center"><b><font size="4">BindMenuEvent()</font></b></p>
<p><b>Syntax</b></p><blockquote>
<font color="#3A3966"><b>BindMenuEvent</b></font>(#Menu, MenuItem, @Callback())</blockquote>

</blockquote>
<b>Description</b><br><blockquote>

Bind a menu event to a callback. It's an additional way to handle events in PureBasic, 
which works without problem with the regulars <a href="../window/windowevent.html">WindowEvent()</a> / <a href="../window/waitwindowevent.html">WaitWindowEvent()</a> 
commands. A menu event can be unbinded with <a href="unbindmenuevent.html">UnbindMenuEvent()</a>. 

</blockquote><p><b>Parameters</b></p><blockquote>
<style type="text/css">
table.parameters { border-spacing: 0px; border-style: none; border-collapse: collapse; }
table.parameters td { border-width: 1px; padding: 6px; border-style: solid; border-color: gray; vertical-align: top; font-family:Arial; font-size:10pt; }
</style>
<table width="90%" class="parameters">
<tr><td width="10%"><i>#Menu</i></td>
<td width="90%"> 
The menu to bind the event to. 

</td></tr>
<tr><td><i>MenuItem</i></td>
<td> 
The menu item within the menu to bind the event to. 

</td></tr>
<tr><td><i>@Callback()</i></td>
<td> 
The callback procedure to call when the event occurs. It has to be declared like this: 
<pre><font face="Courier New, Courier, mono"size="2">  <b><font color="#3A3966">Procedure</font></b> <font color="#3A3966">EventHandler</font>()
    <font color="#3A3966">; Code</font>
  <b><font color="#3A3966">EndProcedure</font></b>
</font></pre>
Regular functions like <a href="../window/eventgadget.html">EventGadget()</a>, <a href="../window/eventwindow.html">EventWindow()</a>, <a href="../window/eventmenu.html">EventMenu()</a>, <a href="../window/eventtype.html">EventType()</a> and <a href="../window/eventdata.html">EventData()</a> are 
available within the callback to get more information about the event. <br>
<br>
Note: <a href="../window/windowevent.html">WindowEvent()</a> and <a href="../window/waitwindowevent.html">WaitWindowEvent()</a> should never be called from inside the callback 
or the program can be locked or have wrong behavior. 

</td></tr>
</table>
</blockquote><p><b>Return value</b></p><blockquote>
None.


</blockquote><p><b>Example</b></p><blockquote>

<pre><font face="Courier New, Courier, mono"size="2">  <b><font color="#3A3966">Procedure</font></b> <font color="#3A3966">TestHandler</font>()
    <b><font color="#3A3966">Debug</font></b> &quot;Test menu event&quot;
  <b><font color="#3A3966">EndProcedure</font></b>
  
  <b><font color="#3A3966">Procedure</font></b> <font color="#3A3966">QuitHandler</font>()
    <b><font color="#3A3966">Debug</font></b> &quot;Quit menu event&quot;
    <b><font color="#3A3966">End</font></b>
  <b><font color="#3A3966">EndProcedure</font></b>
  
<font color="#3A3966">  OpenWindow</font>(0, 100, 100, 200, 50, &quot;Click test&quot;, <font color="#924B72">#PB_Window_SystemMenu</font>)
  
<font color="#3A3966">  CreateMenu</font>(0,<font color="#3A3966"> WindowID</font>(0))
<font color="#3A3966">    MenuTitle</font>(&quot;File&quot;)
<font color="#3A3966">      MenuItem</font>(0, &quot;Test&quot;)
<font color="#3A3966">      MenuItem</font>(1, &quot;Quit&quot;)
  
<font color="#3A3966">  BindMenuEvent</font>(0, 0, @TestHandler())
<font color="#3A3966">  BindMenuEvent</font>(0, 1, @QuitHandler())
  
  <b><font color="#3A3966">Repeat</font></b>
    Event =<font color="#3A3966"> WaitWindowEvent</font>()
  <b><font color="#3A3966">Until</font></b> Event = <font color="#924B72">#PB_Event_CloseWindow</font>
</font></pre>

</blockquote><p><b>See Also</b></p><blockquote>
<a href="../gadget/bindgadgetevent.html">BindGadgetEvent()</a>, <a href="bindmenuevent.html">BindMenuEvent()</a>, <a href="../window/unbindevent.html">UnbindEvent()</a>, <a href="../window/windowevent.html">WindowEvent()</a>, <a href="../window/waitwindowevent.html">WaitWindowEvent()</a> 

</Blockquote><p><b>Supported OS </b><Blockquote>All</Blockquote></p><center><a href="index.html">Menu Index</a> - <a href="closesubmenu.html">CloseSubMenu()</a> -><br><br>

</body></html>